package cfca.seal.util;

import cfca.sadk.algorithm.common.GenKeyAttribute;
import cfca.sadk.algorithm.common.Mechanism;
import cfca.sadk.algorithm.common.PKIException;
import cfca.sadk.lib.crypto.Session;
import cfca.sadk.util.KeyUtil;
import java.security.KeyPair;
import java.security.PrivateKey;

public class JHARDUtil
{
  public static PrivateKey getPrivateKeyFromHard(String keyId, Session session)
    throws PKIException
  {
    KeyPair keyPair = null;
    GenKeyAttribute attr = new GenKeyAttribute();
    attr.isExport = false;
    attr.keyNum = Integer.parseInt(keyId);
    Mechanism mechanism = new Mechanism("RSA");
    mechanism.setParam(attr);
    keyPair = KeyUtil.generateKeyPair(mechanism, 0, session);
    return keyPair.getPrivate();
  }
}